package thread.java20221220;

public class Demo27 {
    public static void main(String[] args) {
        Object o = new Object();
        Object o1 = new Object();
        Thread t1 = new Thread(()->{
            //任务1
            //任务2
            synchronized (o){
                for (int i = 0; i < 1000; i++) {
                    System.out.println("11111");
                }
            }
            System.out.println("3333333333333333333");
        });

        Thread t2 = new Thread(()->{
            //任务3
            //任务4
            synchronized (o1){
                for (int i = 0; i < 1000; i++) {
                    System.out.println("22222");
                }
            }
            System.out.println("4444");
        });

        t1.start();
        t2.start();
    }
}
